package com.hyou.demos.rabbitmq.send;

import java.util.UUID;

import javax.annotation.Resource;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.support.CorrelationData;
import org.springframework.stereotype.Component;

import com.hyou.demos.rabbitmq.consts.ConstantsMQ;

@Component("sender")
public class Sender {
    
    @Resource
    private RabbitTemplate rabbitTemplate;
    
    public void sendMsg(String content) {
        CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
        rabbitTemplate.convertAndSend(ConstantsMQ.EXCHANGE, ConstantsMQ.ROUTINGKEY, content, correlationId);
    }
    
}
